<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>交易所修改</title>
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/global.css" media="all">
    <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/table.css"/>
    <script type="text/javascript" src="/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="/js/global-config.js"></script>
     <style>
        .layui-form-label {
            width: 10%;
        }
        .layui-input-block {
            margin-left: 13%;
        }
        img {
            width: 200px;
            height: 120px;
        }
        .layui-upload-list {
            margin-left: 13%;
        }
    </style>
</head>
<body>
<div style="margin: 15px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>添加交易所(<label class="layui-required-tip">标红的为必填项</label>)</legend>
    </fieldset>
    <form class="layui-form" id="layui-form" action="/manage/exchange/exchangeAdd" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label layui-required-tip">交易所名称：</label>
            <div class="layui-input-block">
                <input type="text" id="exchangeName" maxlength="100" name="exchangeName" value="${data.exchangeName!}" required  lay-verify="required" placeholder="请输入交易所名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-required-tip">交易所别名：</label>
            <div class="layui-input-block">
                <input type="text" id="exchangeAliasName" name="exchangeAliasName" maxlength="100" lay-verify="required"  value="${data.exchangeAliasName!}" placeholder="请输入交易所别名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-required-tip">官网地址：</label>
            <div class="layui-input-block">
                <input type="text" maxlength="100" id="officialWebsiteAddres" name="officialWebsiteAddres" value="${data.officialWebsiteAddres!}" lay-verify="required" placeholder="请输入官网地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
                <label class="layui-form-label layui-required-tip">所在地：</label>
                <div class="layui-input-block" id="countryId">
<!--                   <select  id="province" name="countryId" class="layui-input" lay-verify="required" style="padding: 0px 20px;"  lay-search>
                    <option value="">直接选择或搜索选择</option>
                    <#if areaList??>
							<#list areaList as al>
                                 <#if (data.countryId??) && al.id==data.countryId>
                                    <option value="${al.id}" selected="selected">${al.name!}</option>
                                <#else>
                                    <option value="${al.id}" >${al.name!}</option>
                                </#if>
							</#list>
					</#if>
                    </select>-->
                </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-required-tip">指数：</label>
            <div class="layui-input-block">
                <input type="text" id="index" maxlength="5" name="index" lay-verify="required|number" value="${data.index!}" placeholder="请输入指数" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序：</label>
            <div class="layui-input-block">
                <input type="text" id="sort" maxlength="5" name="sort" lay-verify="required|number" autocomplete="off" class="layui-input" value="${data.sort!}">
            </div>
        </div>
        <div class="layui-form-item" style="display: none;">
            <label class="layui-form-label">状态：</label>
            <div class="layui-input-block" id="enableFlag" >
                <#if  (data.enableFlag)?? && data.enableFlag==true>
			        <input type="radio" name="enableFlag" value="1" title="启用" checked/>
			        <input type="radio" name="enableFlag" value="0" title="停用" />
		        <#else>
			        <input type="radio" name="enableFlag" value="1" title="启用" />
			        <input type="radio" name="enableFlag" value="0" title="停用" checked/>
		        </#if>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否前十：</label>
            <div class="layui-input-block" id="rankTenFlag" >
                <#if  (data.rankTenFlag)?? && data.rankTenFlag==true>
                    <input type="radio" name="rankTenFlag" value="1" title="是" checked/>
                    <input type="radio" name="rankTenFlag" value="0" title="否" />
                    <#else>
                        <input type="radio" name="rankTenFlag" value="1" title="是" />
                        <input type="radio" name="rankTenFlag" value="0" title="否" checked/>
                </#if>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">交易所K线状态：</label>
            <div class="layui-input-block" id="klineStatus" >
                <#if  (data.klineStatus)?? && data.klineStatus==true>
                        <input type="radio" name="klineStatus" value="1" title="启用" checked/>
                        <input type="radio" name="klineStatus" value="0" title="停用" />
                    <#else>
                        <input type="radio" name="klineStatus" value="1" title="启用" />
                        <input type="radio" name="klineStatus" value="0" title="停用" checked/>
                </#if>
            </div>
        </div>
       
        
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
                <button type="button" onclick="javascript:history.back();" class="layui-btn layui-btn-primary" >返回</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.config({
        base: '/js/' //假设这是你存放拓展模块的根目录
    }).extend({ //设定模块别名
        selectN: 'selectN' //如果 mymod.js 是在根目录，也可以不用设定别名
    });
    layui.use(['jquery','table','laydate','layer','form','util','selectN'],function(){
        var $=layui.jquery,table=layui.table,laydate = layui.laydate,
            layer = layui.layer,form = layui.form,util=layui.util,selectN=layui.selectN;
            //无限极联动下拉框
            var countryId = selectN({
                elem: '#countryId'
                ,data: "/manage/exchange/selSysArea"
                ,last:true
                ,sync:false
                ,tips: '请选择'
                ,field:{idName:'id',titleName:'name',childName:'children'}
            });

            var str = "${areaStr!}";

            //设置默认选择值
            var res = reverse(str);
            countryId.set(res);

          //监听提交
            form.on('submit(save)', function(data){
           	if(countryId.isSelected){
           		 data.field.countryName=countryId.lastName;
           	}
           	else{
                layer.msg("请选择所在地",{icon:5, shift: 6 });
                return false;
            }
             data.field.id="${data.id}";
          	  $.ajax({
                    type : "POST",
                    url : "/manage/exchange/updateExchange",
                    dataType : "json",
                    data :data.field,
                    success : function(data) {
                  	  layer.alert(data.msg, {
                  		    skin: 'layui-layer-molv' //样式类名  自定义样式
                  		    ,closeBtn: 1    // 是否显示关闭按钮
                  		    ,anim: 1 //动画类型
                  		    ,btn: ['确定'] //按钮
                  		    ,icon: data.code>=0?1:2    // icon
                  		    ,yes:function(index){
                  		    	if (data.code >= 0) {
                  	                  location.href = "/manage/exchange/exchangeInfoList";
                  	              }else{
                  	            	  layer.close(index);
                  	              }
                  		    }});
                    },
                    error : function() {
                        alert("系统异常,请稍后重试");
                    }
                });
              return false;
            });

            //处理字符串（翻转及转换类型）
            function reverse(str) {
                var strArr=str.split(",");
                for (var i = 0; i < strArr.length/2; i++) {
                    var temp = strArr[i];
                    strArr[i] = strArr[strArr.length-1-i];
                    strArr[strArr.length-1-i] = temp;
                }
                var arrs =[];
                for(var i=0;i<strArr.length;i++){
                    arrs[i]=parseInt(strArr[i]);
                }
                return arrs;
            }
    })
</script>
</body>
</html>